/*
 * GameManager.h
 *
 *  Created on: 18.11.2009
 *      Author: Sergej Schmidt
 */

#ifndef GAMEMANAGER_H_
#define GAMEMANAGER_H_

#include <vector>
#include <Ogre.h>
#include <OgreSingleton.h>
#include <OIS.h>
#include <MyGUI.h>

#include "InputManager.h"
#include "Parser.h"

class GameState;

class GameManager : public Ogre::FrameListener, public Ogre::Singleton<GameManager>,public OIS::KeyListener, OIS::MouseListener
{
public:
	GameManager();
	virtual ~GameManager();
	void start(GameState* state);
	void changeState(GameState* state);
	void pushState(GameState* state);
	void popState();
	static GameManager& getSingleton(void);
	static GameManager* getSingletonPtr(void);

	Ogre::SceneManager* getSceneManager(void) 	{ return m_pSceneManager; }
	Ogre::Camera*		getCamera(void) 		{ return m_pCamera; }
	Ogre::Viewport*		getViewport(void)		{ return m_pViewport; }
	MyGUI::Gui*			getGui(void) 			{ return m_pGui; }
	Parser*				getSpracheParser(void)		{ return m_pSpracheParser; }
	void				LoadSprache(void);
	Parser*				getOptionParser(void)		{ return m_pOptionParser; }
protected:
	Ogre::Root*				m_pRoot;
	Ogre::RenderWindow*		m_pRenderWindow;
	Ogre::SceneManager*		m_pSceneManager;
	Ogre::Camera*			m_pCamera;
	Ogre::Viewport*			m_pViewport;
	MyGUI::Gui*				m_pGui;
	Parser*					m_pSpracheParser;
	Parser*					m_pOptionParser;

	void setupResources(void);
	bool configure(void);
	bool frameStarted(const Ogre::FrameEvent& evt);
	bool frameEnded(const Ogre::FrameEvent& evt);
private:
	// Клватура
	bool keyPressed(const OIS::KeyEvent& e);
	bool keyReleased(const OIS::KeyEvent& e);
	// Мыш
	bool mouseMoved(const OIS::MouseEvent& e);
	bool mousePressed(const OIS::MouseEvent& e, OIS::MouseButtonID id);
	bool mouseReleased(const OIS::MouseEvent& e, OIS::MouseButtonID id);

	InputManager*	m_pInputManager;
	std::vector<GameState*>	m_vecStates;
};
#endif /* GAMEMANAGER_H_ */
